package com.stx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.stx.controller.JudgeController;
import com.stx.mapper.RuanyueMapper;
import com.stx.pojo.Ruanyue;
import com.stx.service.IRuanyueService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RuanyueServiceImpl extends ServiceImpl<RuanyueMapper, Ruanyue> implements IRuanyueService {

    private static final Logger logger = LogManager.getLogger(RuanyueServiceImpl.class);
    @Override
    public boolean findState(Ruanyue ruanyue) {
        LambdaQueryWrapper<Ruanyue> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Ruanyue::getRuaState, ruanyue.getRuaState());
        Ruanyue ruanyue1 = baseMapper.selectOne(queryWrapper);
        if (ruanyue1 == null){
            return false;
        }
        logger.trace("查询状态为："+ruanyue.getRuaState());
        if (ruanyue1.getId() == ruanyue.getId()) {
            return false;
        }
        return true;
    }
}
